part of pp_net;

class PPNetConfig {
  static final instance = PPNetConfig._();
  PPNetConfig._();

  bool _isDebug = false;
  bool get isDebug => _isDebug;

  String _baseUrl = "";
  String get baseUrl => _baseUrl;

  String? _userAgent;
  String? get userAgent => _userAgent;

  String _buildNumber = "";
  String get buildNumber => _buildNumber;

  String? _proxyAddress;
  String? get proxyAddress => _proxyAddress;

  int? _successCode;
  int get successCode => _successCode ?? 200;

  final List<Interceptor> _interceptors = [];

  void addInterceptor(Interceptor interceptor) {
    _interceptors.add(interceptor);
  }

  void setup({
    bool? isDebug,
    String? baseUrl,
    String? userAgent,
    String? buildNumber,
    String? proxyAddress,
    int? successCode,
  }) {
    if (isDebug != null) {
      _isDebug = isDebug;
    }

    if (baseUrl != null) {
      _baseUrl = baseUrl;
    }

    if (userAgent != null) {
      _userAgent = userAgent;
    }
    if (buildNumber != null) {
      _buildNumber = buildNumber;
    }
    if (proxyAddress != null) {
      _proxyAddress = proxyAddress;
    }
    if (successCode != null) {
      _successCode = successCode;
    }
  }
}
